﻿using System;

using System.Collections.Generic;
using System.Text;
using PublicTransport.DAL;
using PublicTransport.DAL.DTO;

namespace PublicTransport.Views.DTO
{
    /// <summary>   Trieda, ktorá obaľuje samotný výsledok hľadania do objektu,
    /// 			ktorý je ľahšie vykresliteľný v gride. Nemá žiadnu funkčnú hodnotu
    /// 			  </summary>
    class TransitWrapperDTO
    {
        private String time;
        private String line;
        private String destinationStation;
        private int travelTime;
        private static StationDao stationDao;
        private static LineDao lineDao;

        public static List<TransitWrapperDTO> Convert(List<PublicTransport.Services.Step2.Transit> transitBOs)
        {
            if (stationDao == null)
                stationDao = new StationDao();
            if (lineDao == null)
                lineDao = new LineDao();
            List<TransitWrapperDTO> wrappedTransits = new List<TransitWrapperDTO>();
            foreach (PublicTransport.Services.Step2.Transit transitBo in transitBOs)
            {
                TransitWrapperDTO transitWrapper = new TransitWrapperDTO();
                transitWrapper.time = transitBo.Time.ToString();
                LineDTO line = lineDao.GetLine(transitBo.LineWhichTakeYouHere);
                String[] name = line.Name.Split('|');
                transitWrapper.line = name[0];
                transitWrapper.DestinationStation = stationDao.GetStation(transitBo.StationID).Name;
                //transitWrapper.travelTime = transitBo.Time;

                wrappedTransits.Add(transitWrapper);
            }
            return wrappedTransits;
            
            return null;
        }

        public String Time
        {
            get { return time; }
            set { time = value; }
        }

        public String Line
        {
            get { return line; }
            set { line = value; }
        }

        public String DestinationStation
        {
            get { return destinationStation; }
            set { destinationStation = value; }
        }

        public int TravelTime
        {
            get { return travelTime; }
            set { travelTime = value; }
        }
    }
}
